<include file="theme/functions"/>
<include file="public@head"/>
<style>
    .form-control-widget-title {
        border: none;
        width:auto;
        padding: 0;
        margin: 0;
        font-size: inherit;
        line-height: inherit;
        background: transparent;
    }

    .form-control-widget-title:focus {
        outline: none;
        background: #fff;
    }
</style>
</head>
<body>

<notempty name="has_file">
    <div class="layui-fluid wrap" id="component-tabs">
        <div class="layui-row">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">模板设计</div>
                    <div class="layui-card-body">
                        <div class="layui-tab">
                            <ul class="layui-tab-title">
                                <li class="layui-this"><a
                                        href="{:url('theme/fileSetting',['file_id'=>$file_id,'tab'=>'widget'])}">组件</a>
                                </li>
                                <notempty name="file.more.vars">
                                    <li><a href="{:url('theme/fileSetting',['file_id'=>$file_id,'tab'=>'var'])}">设置</a>
                                    </li>
                                </notempty>
                                <notempty name="has_public_var">
                                    <li><a href="{:url('theme/fileSetting',['file_id'=>$file_id,'tab'=>'public_var'])}">全局设置</a>
                                    </li>
                                </notempty>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <form method="post" class="layui-form js-ajax-form"
                                          action="{:url('theme/settingPost')}">
                                        <div class="layui-btn-container">
                                            <a href="javascript:parent.openIframeLayer('{:url('admin/Nav/index')}','导航管理')"
                                               class="layui-btn layui-btn-fluid">导航管理</a>
                                            <a href="javascript:parent.openIframeLayer('{:url('admin/Slide/index')}','幻灯片管理')"
                                               class="layui-btn layui-btn-fluid">幻灯片管理</a>
                                            <a href="javascript:parent.openIframeLayer('{:url('admin/Link/index')}','友情链接管理')"
                                               class="layui-btn layui-btn-fluid">友情链接管理</a>
                                        </div>
                                        <notempty name="has_widget">
                                            <foreach name="files" item="file">
                                                <notempty name="file['more']['widgets']">
                                                    <div id="accordion" role="tablist" aria-multiselectable="true">
                                                        <foreach name="file['more']['widgets']" item="widget"
                                                                 key="widgetName" index="index">
                                                            <fieldset class="layui-elem-field" style="margin-top:50px;">
                                                                <legend>
                                                                    <!--<a role="button" data-toggle="collapse" data-parent="#accordion"-->
                                                                    <!--href="#collapse-{$widgetName}">-->
                                                                    <!--{$widget.title}-->
                                                                    <!--</a>-->
                                                                    <input class="form-control-widget-title" type="text" value="{$widget.title}"
                                                                           name="files[{$file.id}][widget][{$widgetName}][title]">

                                                                </legend>
                                                                <div class="layui-field-box" id="collapse-{$widgetName}" role="tabpanel">

                                                                    <div class="panel-body">
                                                                        <php>
                                                                            $display_checked=empty($widget['display'])?'':'checked';
                                                                        </php>
                                                                        <input lay-skin="primary" type="checkbox"
                                                                               name="files[{$file.id}][widget][{$widgetName}][display]"
                                                                               value="1" {$display_checked}>
                                                                        <span style="font-size:18px;">显示</span>
                                                                        {:_parse_vars($widget.vars,'files['.$file['id'].'][widget_vars]['.$widgetName.']',1,$widgetName,$file['id'])}
                                                                        <notempty name="file.is_public">
                                                                            <span class="pull-right label label-success">公共组件</span>
                                                                            <!--<a class="pull-right" title="公共组件" data-toggle="tooltip"><i class="fa fa-question-circle"></i></a>-->
                                                                        </notempty>
                                                                    </div>

                                                                </div>
                                                            </fieldset>
                                                        </foreach>
                                                    </div>
                                                    <else/>
                                                </notempty>
                                            </foreach>
                                            <else/>
                                        </notempty>
                                        <div class="layui-form-item layui-layout-admin">
                                            <div class="layui-input-block">
                                                <div class="layui-footer" style="left: 0;display: none;">
                                                    <input type="hidden" name="id" value="{$file.id}">
                                                    <button type="submit" class="layui-btn js-ajax-submit" id="submit-btn" data-success="successCallback">
                                                        {:lang('SAVE')}
                                                    </button>
                                                </div>
                                            </div>
                                        </div>

                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <include file="theme/scripts"/>
    <script>
        parent.showDesignBtn();
    </script>
</notempty>
<empty name="has_file">
    <script>
        parent.hideDesignBtn();
    </script>
</empty>
<script>
    function successCallback(data, statusText, xhr, $form) {
        function _refresh() {
            if (data.url) {
                //返回带跳转地址
                window.location.href = data.url;
            } else {
                if (data.code == 1) {
                    //刷新当前页
                    reloadPage(window);
                }
            }
        }
        layer.msg(data.msg, {time: 2000 ,offset: '100px'}, function(){
            if (parent.afterSaveSetting) {
                parent.afterSaveSetting();
            }
            _refresh();
        });
    }
</script>
</body>
</html>